<?php

namespace Admin\Controller;
use Think\Controller;

class GuestbookController extends Controller{

        function showlist(){
            $guestbook=new \Model\GuestbookModel();
            $guestbook_info=$guestbook->order('id desc')->select();
            $this->assign('guestbook_info',$guestbook_info);
            $this->display();
        }

        function shanchu($id){
            $guestbook=D('Guestbook');
            $return=$guestbook->delete($id);
            if($return){
                $this->redirect('showlist',array(),'0','删除成功');
            }else{
                $this->redirect('showlist',array(),'2','删除失败');
            }
            $this->display();
    }
        function update($id){
            $guestbook=D('Guestbook');
            if(!empty(I('POST.content'))){
            $return=$guestbook->where("id=$id")->save(I('POST.'));
            if($return){
                $this->redirect('showlist',array(),'1','<h2>修改成功</h2>');
            }else{
                $this->redirect('update',array('id'=>$id),'5','<h2>修改失败</h2>');
            }
        }
            $info=$guestbook->find($id);
            $this->assign('info',$info);
            $this->display();
    }
}

?>
